<?php
namespace Home\Model;
use Think\Model;
class FriendsModel extends Model {
	protected $tableName = 'friends';
	/**
	 * 添加好友
	 * @param number $user_id
	 * @param number $friend_id
	 * @return boolean
	 */
	public function addFriend($user_id=0,$friend_id=0){
		if(empty($user_id) || empty($friend_id)){
			return false;
		}
		$d = array(
				'user_id'		=> $user_id,
				'friend_id'		=> $friend_id
		);		
		if($this->create($d)){
			return $this->add();
		}
		return false;
	}
	/**
	 * 删除好友
	 * @param number $user_id
	 * @param number $friend_id
	 * @return boolean
	 */
	public function delFriend($user_id=0,$friend_id=0){
		if(empty($user_id) || empty($friend_id)){
			return false;
		}
		$w = array(
				'user_id'	=> $user_id,
				'friend_id'	=> $friend_id
		);		
		return $this->where($w)->delete();
	}
}
?>